/**
 * https://leetcode.cn/problems/swap-nodes-in-pairs/submissions/561193973/
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution {
    public ListNode swapPairs(ListNode head) {
        if(head == null || head.next == null) return head;

        //宏观角度看待递归
        //不关注递归的内部展开，把它当做一个黑盒子，并相信它一定能够完成
        ListNode tmp = swapPairs(head.next.next);
        ListNode newHead = head.next;
        newHead.next = head;
        head.next = tmp;

        return newHead;
    }
}